package net.zui.test.comp;

import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.Image;
import java.io.IOException;

import net.zui.comp.ZBaseFrame;
import net.zui.comp.ZButton;
import net.zui.comp.ZLabel;
import net.zui.comp.ZRect;
import net.zui.comp.ZText;
import net.zui.entity.ZBorder;
import net.zui.entity.ZImage;
import net.zui.entity.ZTextRender;
import net.zui.util.UDraw;
import net.zui.util.UIO;

public class MainFrame extends ZBaseFrame {
	private static final long serialVersionUID = 1L;
	
	public MainFrame(String id) throws HeadlessException {
		super(id);
	}
	
	public MainFrame(String id, String title) throws HeadlessException {
		super(id, title);
	}
	
	@Override
	protected void init() {
		setSize(600, 500);
		setLocation(500, 200);
		ZRect rect=new ZRect(this, 100, 200,Color.blue);
		rect.setBorder(new ZBorder(2, 20,Color.red));
		
		rect=new ZRect(this, 100, 200,105,205,Color.orange);
		rect.setBorder(new ZBorder(12, 15, Color.pink));
		
		rect=new ZRect(this,170,10, 200,105,new Color(255, 255, 255, 30));
		//rect.setBorder(new ZBorder(7, 15, Color.CYAN));
		
		rect=new ZRect(this,50,210, 50,90,new Color(255, 255, 255, 125));
		//rect.setBorder(new ZBorder(2, 15, Color.white));
		
		ZImage zi;
		Image img=null,img1=null;
		try {
			img=UIO.loadImage("/img/dd.jpg", this.getClass());
			img1=UIO.loadImage("/img/1.png", this.getClass());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		ZLabel label = new ZLabel("zlabel1", this, 30, 20, 180, 110,-1);
		zi=new ZImage.Default(img);
		label.setImage(zi);
		
		label = new ZLabel("zlabel2", this, 230, 20, 180, 110,-1);
		zi=new ZImage.Center(img);
		label.setImage(zi);
		label.setText(new ZTextRender.Shadow("zlabel2",UDraw.web("eee"),Color.WHITE));
		
		label = new ZLabel("zlabel3", this, 30, 150, 180, 110,-1);
		zi=new ZImage.Fill(img);
		label.setImage(zi);
		label.setText(new ZTextRender.Shadow("zlabel3",Color.WHITE));
		
		label = new ZLabel("zlabel4", this, 230, 150, 180, 110,-1);
		zi=new ZImage.Fill(img);
		label.setImage(zi);
		
		label = new ZLabel("zlabel5", this, 0, 0, getInnerWidth(), getInnerHeight(),99);
		zi=new ZImage.Fill(img1);
		label.setImage(zi);
		label.setAble(false);
		
		new ZButton("ZButton1", this, 260, 270, 100, 50, "我有整容了！");
		
		ZButton button = new ZButton("ZButton2", this, 380, 270, 100, 50, "I`m free！");
		button.setAble(false);
		
		new ZText("text1", this, 380, 340, 100, 50, "hello");
		
		dispather.regAction(new MainAction1(this));
	}

	@Override
	protected void afterInit() {
		/*
		for(ZBase base:getManager().bases()) {
			System.out.println(base);
		}
		*/
	}

}
